'''
--  @owner:opentestcase005
--  @date:2020/11/10
--  @testpoint:设置所属模式,语法中不使用to或者=，合理报错
'''
import sys
import unittest
sys.path.append(sys.path[0]+"/../")
from testcase.utils.Logger import Logger
from testcase.utils.Constant import Constant
from testcase.utils.CommonSH import CommonSH


logger = Logger()
commonsh = CommonSH('dbuser')
constant = Constant()

class SYS_Operation(unittest.TestCase):
    def setUp(self):
        logger.info('------------------------Opengauss_Function_DML_Set_Case0127开始执行-----------------------------')

    def test_reset(self):
        # 设置所属模式,合理报错
        sql_cmd1 = commonsh.execut_db_sql('''show CURRENT_SCHEMA;
                                       drop schema if exists my_schema1 cascade;
                                       create schema my_schema1;
                                       set session CURRENT_SCHEMA !=my_schema1;
                                       set session CURRENT_SCHEMA to = my_schema1;''')
        logger.info(sql_cmd1)
        self.assertIn('"$user",public', sql_cmd1)
        self.assertIn(constant.CREATE_SCHEMA_SUCCESS_MSG, sql_cmd1)
        self.assertIn('ERROR:  syntax error', sql_cmd1)

    # 清理环境
    def tearDown(self):
        logger.info('----------this is teardown-------')
        sql_cmd2 = commonsh.execut_db_sql('''drop schema my_schema1 cascade;''')
        logger.info('------------------------Opengauss_Function_DML_Set_Case0127执行结束--------------------------')
